home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / e_mac / sys⁄stat.h < prev    next >
Encoding:
Text File  |  1996-07-13  |  3.0 KB  |  124 lines  |  [TEXT/CWIE]

  1. /* sys/stat.h */
  2.  
  3. #ifndef _eSTAT
  4. #define _eSTAT
  5.  
  6. #define lstat e_lstat
  7. #define  stat e_stat
  8.  
  9. /* I'd like to:
  10. #undef _STAT
  11. #include <stat.h>
  12. but it's too broken; see changes marked "-- e" below */
  13.  
  14. #ifndef _TIME
  15. #include <time.h>
  16. #endif
  17.  
  18. // added for e_access.c & mosml -- e
  19. #ifndef F_OK
  20. #include <sys/unistd.h>
  21. #endif
  22.  
  23. /*
  24.  *    Local typedefs for stat struct
  25.  */
  26. typedef unsigned long    mode_t;
  27. typedef unsigned long    ino_t;
  28. typedef unsigned long    dev_t;
  29. typedef short            nlink_t;
  30. typedef unsigned long    uid_t;
  31. typedef unsigned long    gid_t;
  32. typedef long            off_t;
  33.  
  34. #pragma options align=mac68k
  35. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  36.     #pragma import on
  37. #endif
  38.  
  39. // in case they were already define (by including stst.h for example) -- e
  40.  
  41. #undef S_IFMT
  42. #undef S_IFIFO
  43. #undef S_IFCHR
  44. #undef S_IFDIR
  45. #undef S_IFBLK
  46. #undef S_IFREG
  47. #undef S_IFLNK
  48. #undef S_IFSOCK
  49. #undef S_ISFIFO
  50. #undef S_ISCHR
  51. #undef S_ISDIR
  52. #undef S_ISBLK
  53. #undef S_ISREG
  54. #undef S_ISLNK
  55. #undef S_ISSOCK
  56.  
  57. /*
  58.  *    (stat) st_mode bit values (only ones relevant for the Mac)
  59.  *    NB: all modes marked as (GUSI) mean that the mode is used only by GUSI
  60.  *        (Grand Unified Sockets Interface).
  61.  */
  62. #define S_IFMT        0x0E00        /* type of file */  // was 0x0F00 -- e
  63. #define   S_IFIFO    0x0000        /*     fifo queue */  // was 0x0100 -- e
  64. #define   S_IFCHR    0x0200        /*   character special (GUSI) */
  65. #define   S_IFDIR    0x0400        /*   directory */
  66. #define   S_IFBLK    0x0600        /*     blocking stream */
  67. #define   S_IFREG    0x0800        /*   regular */
  68. #define   S_IFLNK    0x0A00        /*   symbolic link */
  69. #define   S_IFSOCK    0x0E00        /*   socket (GUSI) */
  70.  
  71. /*
  72.  *    File type macros
  73.  */
  74. #define S_ISFIFO(m)    (((m)&(S_IFMT)) == (S_IFIFO))
  75. #define S_ISCHR(m)    (((m)&(S_IFMT)) == (S_IFCHR))
  76. #define S_ISDIR(m)    (((m)&(S_IFMT)) == (S_IFDIR))
  77. #define S_ISBLK(m)    (((m)&(S_IFMT)) == (S_IFBLK))
  78. #define S_ISREG(m)    (((m)&(S_IFMT)) == (S_IFREG))
  79. #define S_ISLNK(m)    (((m)&(S_IFMT)) == (S_IFLNK))
  80. #define S_ISSOCK(m)    (((m)&(S_IFMT)) == (S_IFSOCK))
  81.  
  82. struct stat
  83. {
  84.     mode_t        st_mode;        /* File mode; see #define's below */
  85.     ino_t        st_ino;            /* File serial number */
  86.     dev_t        st_dev;            /* ID of device containing this file */
  87.     nlink_t        st_nlink;        /* Number of links */
  88.     uid_t        st_uid;            /* User ID of the file's owner */
  89.     gid_t        st_gid;            /* Group ID of the file's group */
  90.     dev_t        st_rdev;        /* Device type */
  91.     off_t        st_size;        /* File size in bytes */
  92.     time_t        st_atime;        /* Time of last access */
  93.     time_t        st_mtime;        /* Time of last data modification */
  94.     time_t        st_ctime;        /* Time of last file status change */
  95.     long        st_blksize;        /* Optimal blocksize */
  96.     long        st_blocks;        /* blocks allocated for file */
  97. };
  98.  
  99. #ifdef __cplusplus
  100. extern "C" {
  101. #endif
  102.  
  103. int stat( const char *path, struct stat *buf );
  104.  
  105. int lstat( const char *path, struct stat *buf );
  106.  
  107. /* these two don't go here but it works to fool mosml's unix.c -- e */
  108.  
  109. char *realpath( char *linkname, char *buffer );
  110. long readlink( char *linkname, char *buffer, long maxlen );
  111.  
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115.  
  116. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  117.     #pragma import reset
  118. #endif
  119. #pragma options align=reset
  120.  
  121. #endif
  122.  
  123. /* */
  124.